//
//  SEPayAPI.swift
//  SmartEyeForPatient
//
//  Created by qdsg on 2021/4/28.
//

import Moya

enum SEPayAPI {
    /// 支付
    /// 应用类型（1PC,2APP,3公众号）
    /// 支付方式(1-微信NATIVE2-微信APP3-微信JSAPI)
    /// 付款通道（1微信，2支付宝）
    case pay(id: String, payType: Int, payChannel: Int)
}

extension SEPayAPI: TargetType {
    var baseURL: URL {
        return URL(string: SEApiManager.baseUrl)!
    }

    var path: String {
        return "/smarteye/smarteye-inquiry/order/unifiedOrder"
    }

    var method: Moya.Method {
        return .post
    }

    var sampleData: Data {
        return "".data(using: .utf8)!
    }

    var task: Task {
        return .requestParameters(parameters: parameters, encoding: JSONEncoding.default)
    }

    var headers: [String : String]? {
        return SEApiManager.headers
    }

    private var parameters: [String: Any] {
        switch self {
        case let .pay(id, payType, payChannel):
            return ["id": id,
                    "payType": payType,
                    "payChannel": payChannel,
                    "appType": 2]
        }
    }

}
